package homework;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class CreateFile {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        do {
            System.out.println("请输入要创建的文件名");
            String fileName = scan.nextLine();
            File file = new File("./" + fileName);
            if (file.exists()) {
                System.out.println("该文件已存在！");
                continue;
            } else {
                file.createNewFile();
                break;
            }
        } while (true);
    }
}
